﻿using System.Data;

namespace K9Nano.Domain
{
    public interface IReadOnlyDbConnectionFactory
    {
        /// <summary>
        /// <see cref="IDbConnection"/>，仅有查询权限，一般结合Dapper用于复杂查询。自动释放。
        /// </summary>
        IDbConnection ReadOnlyDbConnection { get; }

        /// <summary>
        /// <see cref="IDbConnection"/>，仅有查询权限，一般结合Dapper用于复杂查询。手动释放。
        /// </summary>
        IDbConnection CreateConnection();

        /// <summary>
        /// 将sql中共享库站位符<see cref="K9Nano.Share.K9SharedConstants.SharedSchemePlaceholder"/>替换为实际的共享库
        /// </summary>
        /// <param name="sql"></param>
        /// <returns></returns>
        string PrepareSharedSql(string sql);
    }
}